<?php

namespace Addons\Yjategory;
use Common\Controller\Addon;

/**
 * 三级联动插件
 * @author 尤金251
 */

    class YjategoryAddon extends Addon{

        public $info = array(
            'name'=>'Yjategory',
            'title'=>'三级联动',
            'description'=>'三级联动',
            'status'=>1,
            'author'=>'尤金251',
            'version'=>'0.1'
        );

        public function install(){
            return true;
        }

        public function uninstall(){
            return true;
        }

        //实现的Yjcategory钩子方法
        public function Yjcategory($param){
				$good_category = M($param['name'])->where(array('pid'=>0))->select();
				!$param['value'] || $array[] =  $param['value'];
				if($param['value']){
					!($param['value'] = M($param['name'])->where(array('id'=>$param['value']))->getField('pid')) ||
					($array[] = $param['value']);
				}
				if($param['value']){
					!($param['value'] = M($param['name'])->where(array('id'=>$param['value']))->getField('pid')) ||
					($array[] = $param['value']);
				}
			
				$this->assign('array',$array);
				$this->assign('name',$param['name']);
			
				$this->assign('good_category', $good_category);
				$this->display('Yjcategory');
        }
		

    }